<?php

$seminggu = array("Minggu", "Senin", "Selasa", "Rabu", "Kamis", "Jumat", "Sabtu");
$hari = date("w");
$hari_ini = $seminggu[$hari];

$tgl_db = date('Y-m-d H:i:s');
$tgl_sekarang = date("Ymd");
$tgl_skrg = date("d");
$bln_sekarang = date("m");
$thn_sekarang = date("Y");
$jam_sekarang = date("H:i:s");

$nama_bln = array(1 => "Januari", "Februari", "Maret", "April", "Mei",
    "Juni", "Juli", "Agustus", "September",
    "Oktober", "November", "Desember");

function get_format_waktu_full($waktu) {
    $tgl = date('d-m-Y H:i:s', strtotime($waktu));
    return $tgl;
}

function tgl_indo($tgl) {
    $tanggal = substr($tgl, 8, 2);
    $bulan = getBulan(substr($tgl, 5, 2));
    $tahun = substr($tgl, 0, 4);
    return $tanggal . ' ' . $bulan . ' ' . $tahun;
}

function get_tanggal_from_my($tgl){
    $tanggal = substr($tgl, 8, 2);
    return $tanggal;
}

function get_bulan_from_my($tgl){
    $bulan = substr($tgl, 5, 2);
    return $bulan;
}

function getBulan($bln) {
    switch ($bln) {
        case 1:
            return "Januari";
            break;
        case 2:
            return "Februari";
            break;
        case 3:
            return "Maret";
            break;
        case 4:
            return "April";
            break;
        case 5:
            return "Mei";
            break;
        case 6:
            return "Juni";
            break;
        case 7:
            return "Juli";
            break;
        case 8:
            return "Agustus";
            break;
        case 9:
            return "September";
            break;
        case 10:
            return "Oktober";
            break;
        case 11:
            return "November";
            break;
        case 12:
            return "Desember";
            break;
    }
}

function combotgl($awal, $akhir, $var, $terpilih) {
    echo "<select name=$var>";
    for ($i = $awal; $i <= $akhir; $i++) {
        $lebar = strlen($i);
        switch ($lebar) {
            case 1: {
                    $g = "0" . $i;
                    break;
                }
            case 2: {
                    $g = $i;
                    break;
                }
        }
        if ($i == $terpilih)
            echo "<option value=$g selected>$g</option>";
        else
            echo "<option value=$g>$g</option>";
    }
    echo "</select> ";
}

function combobln($awal, $akhir, $var, $terpilih) {
    echo "<select name=$var>";
    for ($bln = $awal; $bln <= $akhir; $bln++) {
        $lebar = strlen($bln);
        switch ($lebar) {
            case 1: {
                    $b = "0" . $bln;
                    break;
                }
            case 2: {
                    $b = $bln;
                    break;
                }
        }
        if ($bln == $terpilih)
            echo "<option value=$b selected>$b</option>";
        else
            echo "<option value=$b>$b</option>";
    }
    echo "</select> ";
}

function combothn($awal, $akhir, $var, $terpilih) {
    echo "<select name=$var>";
    for ($i = $awal; $i <= $akhir; $i++) {
        if ($i == $terpilih)
            echo "<option value=$i selected>$i</option>";
        else
            echo "<option value=$i>$i</option>";
    }
    echo "</select> ";
}

function combonamabln($awal, $akhir, $var, $terpilih) {
    $nama_bln = array(1 => "Januari", "Februari", "Maret", "April", "Mei",
        "Juni", "Juli", "Agustus", "September",
        "Oktober", "November", "Desember");
    echo "<select name=$var>";
    for ($bln = $awal; $bln <= $akhir; $bln++) {
        if ($bln == $terpilih)
            echo "<option value=$bln selected>$nama_bln[$bln]</option>";
        else
            echo "<option value=$bln>$nama_bln[$bln]</option>";
    }
    echo "</select> ";
}

?>
